// 函数组合

function  compose(f, g) {
  return function (val) {
    return f(g(val))
  }
}

function reverse(array) {
  return array.reverse()
}

function first(array) {
  return array[0]
}

const last = compose(first, reverse)

console.log(last([1,2,3,4,5])) // 5